package twoPointers;

//https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/description/
public class l_LCR_179 {
    public int[] twoSum(int[] price, int target) {
        int n = price.length, left = 0, right = n - 1;

        //双指针, 根据比较结果移动指针
        while(left < right) {
            if(price[left] + price[right] == target) return new int[] {price[left], price[right]};
            else if(price[left] + price[right] < target) ++left;
            else --right;
        }
        return new int[0];
    }
}
